<template>
  <main>
    <van-cell-group>
      <van-cell title="设置登录密码" is-link to="setPassword" />
      <!-- <van-cell title="修改登录密码" is-link to="resetPassword"/> -->
    </van-cell-group>
    <van-button 
      class="default-btn"
      @click="logout"
      block>
      退出登录
    </van-button>
  </main>
</template>

<script>
import { Dialog, Toast } from 'vant';
import { mapActions, mapGetters } from 'vuex';
import * as Api from 'api'

export default {
  name: 'home-view',
  data() {
    return {}
  },
  computed: {
    ...mapGetters([
      'user',
    ])
  },
  created() {
    this.$emit('showTabMenu', false);
  },
  methods: {
    ...mapActions([
      'Logout',
    ]),
    logout() {
      Dialog.confirm({
        title: '提示',
        message: '是否确定退出登录？',
      }).then(() => {
        Api.Logout().then(res => {
          Toast(res.message)
          this.Logout()
          this.$router.push('/login')
        })
        // on confirm
      }).catch(() => {
        // on cancel
      });
      console.log('submit');
    },
  },
  // destroyed() {
  //   this.$emit('showTabMenu', true);
  // }
}
</script>

<style scoped>
main{
  padding-top: 40px;
}
.default-btn{
  margin: 60px auto;
  width: 90%;
}
</style>
